#include "enemyattack2.h"
#include "config.h"

enemyattack2::enemyattack2()
{
    //加载激光资源
    m_enemyattack2.load(ENEMY2_ATTACK_PATH);

    //激光位置
    m_X=GAME_WIDTH;
    m_Y=0;

    //激光状态
    m_Free=true;

    //激光速度
    m_speed=ENEMY_SPEED;

    //激光边框
    m_Rect.setWidth(m_enemyattack2.width());
    m_Rect.setHeight(m_enemyattack2.height());
    m_Rect.moveTo(m_X,m_Y);
}
void enemyattack2::updatePosition()
{
    //空闲激光不计算坐标
    if(m_Free)
        return;
    //不空闲的激光向左移动
    m_X-=m_speed;
    m_Rect.moveTo(m_X,m_Y);
    //激光到左边界
    if(m_X<=-m_Rect.width())
    {
        m_Free=true;//重置空闲状态
    }
}
